//Memoire partagee et semaphore
#include <sys/types.h> 
#include <sys/ipc.h> 
#include <sys/msg.h>
#include <sys/sem.h>
#include <sys/shm.h>

#include "ServerSocket.h"


/*
typedef struct memoirePartageeEtSemaphore{
	int idMP=-1; //ID de la memoire partagee
	int idSem=-1; //ID de la semaphore
	struct sembuf opSem[3]={{0,-1,0},{0,1,0},{0,0,0}}; //Operation du semaphore
}memPetS;
*/

/*
struct sembuf semaphore_op1;
struct sembuf semaphore_op2;
struct sembuf semaphore_op3;

//P(S)
semaphore_op1.sem_num=0;
semaphore_op1.sem_op=-1;
semaphore_op1.sem_flg=SEM_UNDO;
//V(S)
semaphore_op2.sem_num=0;
semaphore_op2.sem_op=1;
semaphore_op2.sem_flg=SEM_UNDO;
//Z(S)
semaphore_op3.sem_num=0;
semaphore_op3.sem_op=0;
semaphore_op3.sem_flg=SEM_UNDO;

//flex.opSem[0]=semaphore_op1;
//flex.opSem[1]=semaphore_op2;
//flex.opSem[2]=semaphore_op3;
*/
typedef struct memoirePartageeEtSemaphore{
	int idMP; //ID de la memoire partagee
	int idSem; //ID de la semaphore
	struct sembuf opSem[3]; //Operation du semaphore
	
	//Constructeur
	memoirePartageeEtSemaphore(){
	idMP=idSem=-1;
	opSem={{0,-1,0},{0,1,0},{0,0,0}};
	}
}memPetS;


typedef struct paramDesThread{
	ServerSocket* server; //Socket du serveur
	memPetS* mem;
}param;


